package fem2.gui.actions;

import inf.timer.JobInfo;
import inf.timer.Timer;
import inf.timer.swing.TimerDialog;
import inf.vtk.pm.PipelineCollection;

import java.awt.Component;
import java.awt.event.ActionEvent;

import javax.swing.JOptionPane;

public class TimeStatisticsAction extends ActionBase {

    private static final long serialVersionUID = 1L;

    public TimeStatisticsAction(PipelineCollection pc) {
        super("Time Statistics", pc);
    }

    public void actionPerformed(ActionEvent actionEvent) {
        JobInfo info = Timer.getInstance().getLastFinished();
        if (info != null) {
            new TimerDialog(info, null, true).setVisible(true);
        }
        else {
            JOptionPane.showMessageDialog((Component) actionEvent.getSource(),
                    "No time statistics available");
        }
    }
}